let list = document.querySelectorAll("#page-content-wrapper div.row div.col-sm-4 .table");

let nameList = document.createElement("div");
nameList.style.display = "none";
document.getElementById("modal").appendChild(nameList);
let urlList = document.createElement("div");
urlList.style.display = "none";
document.getElementById("modal").appendChild(urlList);

let nameMap = {
    "Minami Kotori": ["南小鸟", "μ's"],
    "Hoshizora Rin": ["星空凛", "μ's"],
    "Nishikino Maki": ["西木野真姬", "μ's"],
    "Yazawa Nico": ["矢泽妮可", "μ's"],
    "Koizumi Hanayo": ["小泉花阳", "μ's"],
    "Ayase Eli": ["绚濑绘里", "μ's"],
    "Sonoda Umi": ["园田海未", "μ's"],
    "Toujou Nozomi": ["东条希", "μ's"],
    "Kousaka Honoka": ["高坂穗乃果", "μ's"],
    "Watanabe You": ["渡边曜", "Aqours"],
    "Takami Chika": ["高海千歌", "Aqours"],
    "Kunikida Hanamaru": ["国木田花丸", "Aqours"],
    "Kurosawa Dia": ["黑泽黛雅", "Aqours"],
    "Kurosawa Ruby": ["黑泽露比", "Aqours"],
    "Tsushima Yoshiko": ["津岛善子", "Aqours"],
    "Matsuura Kanan": ["松浦果南", "Aqours"],
    "Ohara Mari": ["小原鞠莉", "Aqours"],
    "Sakurauchi Riko": ["樱内梨子", "Aqours"],
    "Uehara Ayumu": ["上原步梦", "虹团"],
    "Nakasu Kasumi": ["中须霞", "虹团"],
    "Ousaka Shizuku": ["樱坂雫", "虹团"],
    "Asaka Karin": ["朝香果林", "虹团"],
    "Miyashita Ai": ["宫下爱", "虹团"],
    "Konoe Kanata": ["近江彼方", "虹团"],
    "Yuki Setsuna": ["优木雪菜", "虹团"],
    "Emma Verde": ["艾玛·维尔德", "虹团"],
    "Tennoji Rina": ["天王寺璃奈", "虹团"],
    "Mifune Shioriko": ["三船栞子", "虹团"],
}

let urlString2 = "";
let nameString2 = "";

for (let i = 0; i < list.length; i++) {
    var strongDom = list[i].querySelectorAll("strong");
    if (nameMap[strongDom[0].innerHTML] === undefined) {
        continue;
    }

    var name = nameMap[strongDom[0].innerHTML][0];             // 角色名
    var jineng // 技能名
    if (strongDom[1] === undefined) {
        jineng = "null";
    } else {
        jineng = strongDom[1].innerHTML;            // 技能名
    }
    var group = nameMap[strongDom[0].innerHTML][1];             // 队名

    var jibieHTML = list[i].querySelector("tr td>small").innerHTML;
    var jibie = jibieHTML.substring(0, jibieHTML.indexOf(" "));   // 级别：UR SSR等

    var idText = list[i].querySelector("a").innerText;
    var id = /(\d+)/.exec(idText.substring(idText.indexOf("#") + 1))[1];

    var urlDomList;
    var cardDomList = list[i].querySelectorAll("tr");
    for (let j = 0; j < cardDomList.length; j++) {
        if (cardDomList[j].querySelector("th").innerText === "下载") {
            urlDomList = cardDomList[j].querySelectorAll("td a");
            break;
        }
    }
    for (let j = 0; j < urlDomList.length; j++) {
        var url = urlDomList[j].href;
        urlString2 += urlList.innerHTML + urlList.innerHTML + url + "<br>";
        var type = urlDomList[j].innerHTML.split(": ");
        var kapai = "卡牌"
        if (type[0] === "透明") {
            kapai = "立绘"
        }
        var cardname = url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf(".")) + "-" + id + "-" + group + kapai + "-" + name + "-" + jibie + "-" + jineng;
         nameString2 += cardname + "<br />";
    }

    console.log(1);
}

urlList.innerHTML = urlString2;
nameList.innerHTML = nameString2;

console.log("end!");



